<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = new Array(5);
        arr[0] = 1;
        arr[1] = 2;
        arr[2] = 3;

        arr[100] = 100;
        console.log(arr);


        let arrayLike = {
                '1': 'a',
                '2': 'b',
                '3': 'c',
                length: 4
            };
        // arrayLike 对象的格式有要求 key 必须是数字
        // 数组下标从0开始，必须和对象的key 下标对应起来
        let arr2 = Array.from(arrayLike);
        console.log(arr2);


        let arr3 = Array.of(11,22,33);
        console.log(arr3);


        let arr4 = Array.of("a11","b22","c33");
        console.log(arr4);


        let arr5 = new Array(5,10,15);
        console.log(arr5);


        let arr6 = new Array("a11","b22","c33");
        console.log(arr6);

        for (const index of arr6.keys()) {
            console.log(index);
        }

        for (const value of arr6.values()) {
            console.log(value);
        }

        for (const obj of arr6.entries()) {
            console.log(obj); // object
        }

        // 从左到右查找
        // 下标起始位置0开始查找
        //   1   2    3
        //   0   1    2
        //   -3 -2   -1
        console.log([1, 2, 3].includes(3));    
        //  2个参数，从第二个参数指定的下标开始查找
        console.log([1, 2, 3].includes(3,2));  //true
        console.log([1, 2, 3].includes(3,3));  //false
        console.log([1, 2, 3].includes(3,-2));

        console.log([1, 2, 3].includes(3,-100)); // 下标越界了，从0开始


        // indexOf  string 

        console.log([1, 2, [3, [4, 5]]].flat(5));





    </script>
</body>
</html>